package com.tgy.JVM;

import java.util.ArrayList;

/***
 * @ClassName: OOM
 * @Description: 测试OOM
 * @Auther: tanggy3
 * @Date: 15:54 2022/5/12
 * @version : V1.0
 */
public class OOM {
    //-Xms4m -Xmx16m -XX:+HeapDumpOnOutOfMemoryError
    int[] aaa = new int[1024 * 1024];
    public static void main(String[] args) {
        ArrayList<OOM> ooms = new ArrayList<>();
        int count = 0;
        try {
            while (true) {
                ooms.add(new OOM());
                count++;
            }
        } catch (Error e) {
            e.printStackTrace();
            System.out.println("count = " + count);
        }
    }
}
